package com.vietnam.power.persitence;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.vietnam.power.domain.Root;

/**
 * The persistent class for the article_group database table.
 * 
 */
@Entity
@Table(name = "article_group")
public class ArticleGroup implements Serializable, Root {
	private static final long serialVersionUID = 1L;
	private int id;
	private Date createdDate;
	private String description;
	private String keyword;
	private String name;
	private List<Article> articles;

	public ArticleGroup() {
	}

	public ArticleGroup(int id) {
		this.id = id;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "created_date")
	public Date getCreatedDate() {
		return this.createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	@Lob
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getKeyword() {
		return this.keyword;
	}

	public void setKeyword(String keyword) {
		this.keyword = keyword;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	// bi-directional many-to-one association to Article
	@OneToMany(mappedBy = "articleGroup")
	public List<Article> getArticles() {
		return this.articles;
	}

	public void setArticles(List<Article> articles) {
		this.articles = articles;
	}

	public Article addArticle(Article article) {
		getArticles().add(article);
		article.setArticleGroup(this);

		return article;
	}

	public Article removeArticle(Article article) {
		getArticles().remove(article);
		article.setArticleGroup(null);

		return article;
	}

}